/**
 * 新增修改完成调用 modalFormOk方法 编辑弹框组件ref定义为modalForm
 * 高级查询按钮调用 superQuery方法  高级查询组件ref定义为superQueryModal
 * data中url定义 list为查询列表  delete为删除单条记录  deleteBatch为批量删除
 */
import {getAction, postAction} from '@/api/manage'
export const BgPubFun = {
  data() {
    return {

    }
  },
  created() {
  },
  mounted() {

  },
  methods: {
    // 上传文件时调的保存接口
    saveBg( fileId, bgType ) {
      postAction(this.url.saveBg, {
        proId: this.id,
        fileId: fileId,
        type: bgType
      }).then((res) => {
        if (res.success) {
          this.loadData()
        }else{
          this.$message.error(res.message)
        }
      })
    },
    // 提交审核-打开选择审核人弹窗
    showConfirm() {
      if(this.dataSource.length == 0){
        this.$message.warning("请添加数据!")
        return
      }
      this.$refs.approver.showApproveConfirm = true
    },
    // 提交审核
    handleSubmit(userId) {
      getAction(this.url.submit, {
        proId: this.id,
        userId: userId,
        typeId: this.typeId
      }).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
          this.loadData()
        }
      })
    },
    // 填写审核原因
    setApproveReason(status){
      this.approveStatus = status
      this.$refs.setReason.setApproveReason = true
    },
    // 审核
    approveData(reason){
      let remark = this.approveStatus === '9'? `同意：${reason}`: `拒绝：${reason}`
      getAction(this.url.approve, { proId: this.id, status: this.approveStatus, remark: remark, typeId: this.typeId }).then((res) => {
        if (res.success) {
          this.$refs.setReason.setApproveReason = false
          this.loadData()
        }else{
          this.$message.error(res.message)
        }
      })
    },
    handleDownloadFile(fileUrl) {
      this.$message.success('正在下载，请稍等！')
      let url = `${window._CONFIG['domianURL']}/sys/common/download${fileUrl}`
      window.open(url, '_blank')
    },
  }

}